package com.example.design.dahua.chainofresponsibility.old;

import java.text.MessageFormat;

/**
 * @author ebnew
 * 管理者
 */
public class Manager {
    protected String name;

    public Manager(String name) {
        this.name = name;
    }

    /**
     * 得到结果
     * 比较长的方法，多条的分支，这些都是坏代码的味道
     *
     * @param managerLevel
     * @param request
     */
    public void getRequest(String managerLevel, Request request) {
        if ("经理".equals(managerLevel)) {
            if ("请假".equals(request.getRequestType()) && request.getNumber() <= 2) {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 被批准", name, request.getRequestContent(), request.getNumber()));
            } else {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 我无权处理", name, request.getRequestContent(), request.getNumber()));
            }
        } else if ("总监".equals(managerLevel)) {
            if ("请假".equals(request.getRequestType()) && request.getNumber() <= 5) {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 被批准", name, request.getRequestContent(), request.getNumber()));
            } else {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 我无权处理", name, request.getRequestContent(), request.getNumber()));
            }
        } else if ("总经理".equals(managerLevel)) {
            if ("请假".equals(request.getRequestType())) {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 被批准", name, request.getRequestContent(), request.getNumber()));
            } else if ("加薪".equals(request.getRequestType()) && request.getNumber() <= 500) {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 被批准", name, request.getRequestContent(), request.getNumber()));
            } else if ("加薪".equals(request.getRequestType()) && request.getNumber() > 500) {
                System.out.println(MessageFormat.format("{0}:{1} 数量{2} 再等等吧", name, request.getRequestContent(), request.getNumber()));
            }
        }
    }
}
